package xin.yangshuai.basic01.gof23.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Hello {
    public static void main(String[] args) {
        Rent rent = new Landlord();
        Object o = Proxy.newProxyInstance(Landlord.class.getClassLoader(), Landlord.class.getInterfaces(), new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                Object invoke = method.invoke(rent, args);
                System.out.println("hello---------------------------: " + method.getName());
                return invoke;
            }
        });

        System.out.println();

        ((Rent) o).rentHouse();
    }
}
